<template>
    <div class="bac">
        <div class="products">
            <div class="product-display" v-for="(item) in goodsList" :key="item.id">
                <div class="product-img">
                    <img class="shop-img" :src="item.img" @click="toPeoductDetail(item.id)">
                </div>
                <div class="introduction-price">
                    <div class="text">
                        {{ item.introdaction }}
                    </div>
                    <div class="price">
                        <div class="new-price">
                            ${{ item.price }}
                        </div>
                        <div class="old-price" v-if="item.originalPrice">
                            ${{ item.originalPrice }}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import { mapGetters, mapState } from 'vuex'

export default {
    name: 'ShopMune',
    data() {
        return {
            
        }
    },
    methods: {
        toPeoductDetail(id) {
            console.log(id);
            this.$router.push({
                path: '/detail',
                query: {
                    id: id
                }
            })
        }
    },
    // 模块化写法
    // computed: mapState('shopMuneOption', ['goodsList'])
    // 对象写法
    // computed: mapState({
    //     goodsList: state => state.shopMuneOption.goodsList
    // })
    computed: {
        ...mapState({
            goodsList: state => state.shopMuneOption.goodsList
        }),
    },

    mounted() {
    
    }
}
</script>

<style scoped>
.bac {
    width: 100%;
    /* height: 812px; */
    margin-top: 46px;
    margin-bottom: 16px;
    overflow: scroll;
}

.bac::-webkit-scrollbar {
    display: none;
}

.products {
    display: flex;
    flex-wrap: wrap;
    width: 343px;
    margin: 0 auto;
    justify-content: space-between;

}

.product-display {
    width: 164px;
    height: 326px;
    margin-top: 20px;
}

.product-img {
    width: 100%;
    height: 246.07px;
    padding-bottom: 11.93px;
}

.shop-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
}

.introduction-price {
    width: 164px;
    height: 68px;
}

.text {
    display: -webkit-box;
    font-weight: 400;
    font-size: 13px;
    line-height: 20px;
    letter-spacing: 0px;
    text-align: left;
    /* font-family: Inter; */
    overflow: hidden;
    text-overflow: ellipsis;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.price {
    display: block;
    width: 100%;
    height: 20px;
    padding-top: 8px;
}

.new-price {
    display: inline-block;
    height: 100%;
    font-weight: 500;
    font-size: 14px;
    /* font-family: Inter; */
    line-height: 20px;
    letter-spacing: 0;
    text-align: left;
    padding-right: 12px;
}

.old-price {
    display: inline-block;
    height: 100%;
    font-weight: 400;
    font-size: 12px;
    line-height: 16px;
    letter-spacing: 0;
    text-align: left;
    /* font-family: Inter; */
    color: rgb(152, 153, 154);
    text-decoration: line-through;

}
</style>